package com.mlnx.bptp.body;

/**
 * @author zzb
 * @create 2019/3/25 13:56
 */
public enum Command {
    START_BP_DETECT(0x70, "开始检测"), STOP_BP_DETECT(0x71, "停止检测"), QUERY_DEVINFO(0x60, "查询设备信息"),
    BP_DAY_DETECT(0X53,"白天连续测量状态（开/关）"), BP_DAY_TIME(0x54, "设置白天自动测量时间"),
    BP_NIGHT_DETECT(0x55, "夜间自动测量状态（开/关）"),BP_NIGHT_TIME(0x56, "设置夜间自动测量时间"),
    LAST_BP_RESULT(0x63, "获取最后一次的测量结果"), DEVICE_STATE(0xA3, "设备状态"),RECEIVE_DEVICE_ID(0xA6,"获取设备ID"),
    RECEIVE_BP_RESULT(0x65,"得到血压数据"), PING_PACKET(0xA2,"心跳包"),CURRENT_TIME(0x51,"当前系统时间")
    ,BEGIN(0x5F ,"编程启动"),DELETE_RECORD(0xA9,"清除记录"),ELECTRIC(0X61,"获得电量"),GET_BP_RESULT_NUM(0x64,"获得某时段后记录数");

    private int code;
    private String description;

    private Command(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static Command decode(int code) {
        Command[] commands = Command.values();
        for (int i = 0; i < commands.length; i++) {

            if (code == commands[i].code)
                return commands[i];
        }
        return null;
    }

}
